<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>绝对定位</title>
		<style type="text/css">
			#father{
				width: 400px;
				height: 400px;
				background-color: yellow;
				position: relative;  /*父容器设置了相对定位*/
				left: 100px;
				top: 50px;	
			}
			#father .first{
				width: 100px;
				height: 100px;
				background-color: red;
				/*子元素div1绝对定位,则它就会以父容器左上角为原点进行定位。
				div1脱离文档流，原来的位置会被div2占用*/
				position: absolute;  
				left: 20px;
				top: 20px;
				z-index: 2;
			}
			#father .second{
				width: 200px;
				height: 200px;
				background-color: green;
				position: absolute;  
				left: 50px;
				top: 50px;
				z-index: 1;
			}
		</style>
	</head>
	<body>
		<div id="father">
			<div class="first">div1</div>
			<div class="second">div2</div>			
		</div>
	</body>
</html>
